package flc.ast.widget.calendar;

import android.annotation.SuppressLint;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.graphics.Color;
import android.widget.RemoteViews;

import com.blankj.utilcode.util.TimeUtils;

import java.util.Date;

import flc.ast.R;
import stark.common.basic.utils.BitmapUtil;

public class Calendar4Widget extends BaseCalendarWidget {

    public Calendar4Widget(int appWidgetId) {
        super(appWidgetId);
    }

    @Override
    protected void onUpdate(Context context) {
        @SuppressLint("RemoteViewLayout") RemoteViews remoteViews =
                new RemoteViews(context.getPackageName(), R.layout.widget_calendar4);

        String day = TimeUtils.date2String(new Date(), "dd");
        String date2 = TimeUtils.date2String(new Date(), "yyyy年MM月");
        remoteViews.setImageViewBitmap(R.id.ivCalendar4Date,
                BitmapUtil.text2BmpWithAssetFont(context, date2, Color.parseColor("#010101"),
                        15, "font/ziti7.ttf"));
        remoteViews.setImageViewBitmap(R.id.ivCalendar4Day,
                BitmapUtil.text2BmpWithAssetFont(context, day, Color.parseColor("#010101"),
                        34, "font/ziti7.ttf"));

        AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteViews);
    }
}
